﻿using Net.Sz.Framework.Netty;
using Net.Sz.Framework.Netty.Buffer;
using Net.Sz.Framework.Szlog;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;

namespace SocketGate
{
    class Program
    {
        private static SzLogger log = SzLogger.getLogger();

        static void Main(string[] args)
        {
            /*优先创建处理客户端连接的 handler程序*/
            NettyPool.SessionHandler = new Handler();
            /*开启socket的监听*/
            NettyPool.AddTcpBind("0.0.0.0", 9527);
            log.Info("我是网关服务器");
            Console.ReadLine();
        }


        /// <summary>
        /// 处理客户端连接的 handler程序
        /// </summary>
        class Handler : IIOSessionHandler
        {
            /// <summary>
            /// 当客户端有新的连接，连接进来
            /// </summary>
            /// <param name="session"></param>
            public void ChannelActive(IOSession session)
            {

            }

            /// <summary>
            /// 服务器内部错误
            /// </summary>
            /// <param name="session"></param>
            /// <param name="ex"></param>
            public void ExceptionCaught(IOSession session, Exception ex)
            {

            }

            /// <summary>
            /// 收取客户端消息
            /// </summary>
            /// <param name="session">客户端连接对象</param>
            /// <param name="msgId">本次消息id</param>
            /// <param name="buffer">本次消息报文内容</param>
            public void ChannelRead(IOSession session, int msgId, byte[] buffer)
            {
               
            }

            /// <summary>
            /// 链接断开
            /// </summary>
            /// <param name="session"></param>
            /// <param name="obj"></param>
            public void ChannelUnregistered(IOSession session, params string[] obj)
            {

            }

            /// <summary>
            /// 链接闲置状态
            /// </summary>
            /// <param name="session"></param>
            public void ChannelInactive(IOSession session)
            {

            }
        }
    }
}
